package com.leigang.springboot.kafka.send;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @program: yaner-boot
 * @description: 发送消息到kafka
 * @author: leigang
 * @create: 2020-01-03 00:31
 */
@RestController
public class SendMsgToKafka {
    @Autowired
    private KafkaTemplate<String,Object> kafkaTemplate;

    @GetMapping("/message/send")
    public String send(){
        String message="问好kafka，哈哈";
        kafkaTemplate.send("testTopic",message);
        System.out.println("我已经发送消息"+message);
        return message;
    }

}
